using System.Web.Mvc;
using NUnit.Framework;
using NUnit.Framework.SyntaxHelpers;
using Pronghorn.Core;
using TestDoubles;

namespace ProngHornCore_Tests
{
	[TestFixture]
	public class MinimizeAndCombineJsController_Tests
	{
		[Test]
		public void When_no_files_are_passed_response_is_empty()
		{
			var viewData = new ViewDataDictionary<IProngHornSkinContext>(new StubSkinContext());
			var container = new StubContainer();
			var jscontroller = new MinimizeAndCombineJsController(
				viewData, new SiteContext(), container)
			                   	{
			                   		ControllerContext = StubControllerContext.CreateContext(StubControllerContextTypes.Scripts)
			                   	};

			JavaScriptResult result = jscontroller.Index(string.Empty);
			Assert.That(result.Script.Length, Is.EqualTo(0));
		}

		[Test]
		public void When_file_names_are_passed_write_that_code_to_the_pipeline()
		{
			var viewData = new ViewDataDictionary<IProngHornSkinContext>(new StubSkinContext());
			var container = new StubContainer();
			IProngHornControllerContext context = StubControllerContext.CreateContext(StubControllerContextTypes.Scripts);
			var jscontroller = new MinimizeAndCombineJsController(
				viewData, new SiteContext(), container)
			                   	{
			                   		ControllerContext = context
			                   	};

			JavaScriptResult result = jscontroller.Index("lib-UI.UI|lib-UI.Menu");
			Assert.That(result.Script.Length, Is.Not.EqualTo(0));
		}
	}
}